import numpy as ny
import pandas as pd

data_frame = pd.DataFrame(ny.random.randint(1, 10, (3, 4)), index=list('abc'), columns=list('ABCD'))
print(data_frame)
print(data_frame >= 5)

# 过滤行数据: 过滤条件为A列中数据大于等于5的数值
filter_data_frame = data_frame[data_frame['A'] >= 5]
print(filter_data_frame)

# query方法实现上述功能, 同时还支持链式编程
query_data_frame = data_frame.query('A >= 5')
print(query_data_frame)

# isin方法过滤数据
data_frame_isin = data_frame.isin([5, 8])
print(data_frame_isin)
print(data_frame[data_frame['A'].isin([5, 8])])
